package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolMaintainHandleView;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolMaintainHandleModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolMaintainHandleModel;

/**
 * Created by lenovo on 2018/7/22.
 */

public class PatrolMaintainHandlePresenter {
    private IPatrolMaintainHandleView view;
    private IPatrolMaintainHandleModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolMaintainHandlePresenter(IPatrolMaintainHandleView view) {
        this.view = view;
        this.model = new PatrolMaintainHandleModel();
    }

    public void patrolMaintainHandle() {


        model.patrolMaintainHandle(view.gethandleId(), view.getItemId(), view.getOrderId(), new PatrolMaintainHandleModel.OnPatrolMaintainHandleListener() {
            @Override
            public void patrolMaintainHandleSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.patrolMaintainHandleSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void patrolMaintainHandleFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.patrolMaintainHandleFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
